<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	window.onload = function() {
		var alt = document.querySelector("img").alt;
		console.log("alt:"+alt);
		
		var val = document.querySelector("#input1").value;
		console.log("value:"+val);
		//获取class的值
		var cl = document.querySelector(".class1").className;
		console.log("class:"+cl);
		
		//获取和修改非html属性的值用getAttribute()和setAttribute()
		var src = document.querySelector("#img1").getAttribute("src");
		console.log("get src attribute : "+src);
		document.querySelector("#img1").setAttribute("src", "456.jpg");
	}
</script>
</head>
<body>
	<div id="div1">
		<p id="p1" class="class1">我是第一个P</p>
		<img src="123.jpg" alt="我是一张图片" id="img1" /> 
		<input type="text" value="我是一个文本框" id="input1" />
	</div>
</body>
</html>